﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XiuGaiCBBKZ.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.ChaoBiaoGL.XiuGaiCBBKZ" Theme="Default" %>

<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>修改抄表并开账</title>
    <script src="../../../../JS/jquery.js"></script>
    <script src="../../../../JS/AddEditCancel.js"></script>
    <script type="text/javascript">

        function search()
        {
            if (txtY.GetText()=="")
            {
                alert("请输入水量年");
                txtY.Focus();
                return;
            }
            if (txtM.GetText() == "") {
                alert("请输入水量月");
                txtM.Focus();
                return;
            }
            if (txtSBH.GetText() == "") {
                alert("请输入水表号");
                txtSBH.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("search");
        }

        function edit()
        {
            if (txtYongHuH.GetText() == "") {
                alert("请先查询出抄表数据");
                return;
            }
            txtBenYueCM.SetEnabled(true);
            txtBenYueSL.SetEnabled(true);
            txtQueRenBYSL.SetEnabled(true);
            btnEdit.SetEnabled(false);
            btnKZ.SetEnabled(true);
            btnCancel.SetEnabled(true);
        }
        function kz() {
            if (txtYongHuH.GetText() == "")
            {
                alert("请先查询出抄表数据");
                return;
            }
            if (txtBenYueCM.GetText() == "") {
                alert("请输入本月抄码");
                txtBenYueCM.Focus();
                return;
            }
            if (txtBenYueSL.GetText() == "") {
                alert("请输入本月水量");
                txtBenYueSL.Focus();
                return;
            }
            if (txtQueRenBYSL.GetText() != txtBenYueSL.GetText()) {
                alert("确认本月水量与本月水量不一致");
                txtBenYueSL.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("kz");
        }
        function cancel() {
            txtBenYueCM.SetEnabled(false);
            txtBenYueSL.SetEnabled(false);
            txtQueRenBYSL.SetEnabled(false);
            btnEdit.SetEnabled(true);
            btnKZ.SetEnabled(false);
            btnCancel.SetEnabled(false);
            hdCollection.Set("ID", -1);
            txtYongHuH.SetText("");
            txtYongHuM.SetText("");
            txtJingBianH.SetText("");
            txtBenYueCM.SetText("");
            txtBenYueSL.SetText("");
            txtShangYueCM.SetText("");
            txtShangYueSL.SetText("");
            txtKaiZhangSL.SetText("");
        }
        
        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            var specialIdentity = arr[2];
            var msg = arr[3].split('-');
            if (msg[0] == 'True') {
                alert(msg[1]);
            }
            hdCollection.Set("type", type);
            if (state == 'True') {
                if (type == "search") {
                    //加载信息
                    txtYongHuH.SetText(arr[4]);
                    txtYongHuM.SetText(arr[5]);
                    txtJingBianH.SetText(arr[6]);
                    txtBenYueCM.SetText(arr[7]);
                    txtBenYueSL.SetText(arr[8]);
                    txtShangYueCM.SetText(arr[9]);
                    txtShangYueSL.SetText(arr[10]);
                    txtKaiZhangSL.SetText(arr[11]);
                    hdCollection.Set("ID", specialIdentity);
                    txtQueRenBYSL.Focus();
                }
                else if (type == "del") {
                    gvList.PerformCallback();
                }
                else if (type == "save") {
                    display("init", -1);
                    hdCollection.Set("OperateID", specialIdentity);
                    gvList.PerformCallback();
                }
            }
            else {
                hdCollection.Set("ID", -1);
                txtYongHuH.SetText("");
                txtYongHuM.SetText("");
                txtJingBianH.SetText("");
                txtBenYueCM.SetText("");
                txtBenYueSL.SetText("");
                txtShangYueCM.SetText("");
                txtShangYueSL.SetText("");
                txtKaiZhangSL.SetText("");
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            修改抄表并开账
        </div>
        <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
        <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" ShowImage="false" Text="加载中"></dx:ASPxLoadingPanel>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div>
                    <table style="width: 100%; height:35px;">
                        <tr>
                            <td style="text-align: right;">水量年：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtY" ClientInstanceName="txtY" Width="150px">
                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);OnKeyNext(txtM);}"/>
                                </dx:ASPxTextBox>
                            </td>
                            <td style="text-align: right;">水量月：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtM" ClientInstanceName="txtM" Width="150px">
                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);OnKeyNext(txtSBH);}"/>
                                </dx:ASPxTextBox>
                            </td>
                            <td style="text-align: right;">水表号：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtSBH" ClientInstanceName="txtSBH" Width="150px">
                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);OnKeyNext(btnSearch);}"/>
                                </dx:ASPxTextBox>
                            </td>
                            <td>
                                <dx:ASPxButton runat="server" ID="btnSearch" ClientInstanceName="btnSearch" Text="查询" UseSubmitBehavior="false" AutoPostBack="false">
                                    <ClientSideEvents Click="function(s,e){search();}"/>
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="margin-top:20px;">
                    <table style="width:100%;height:200px;">
                        <tr>
                            <td style="text-align: right;">用户号：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtYongHuH" ClientInstanceName="txtYongHuH" Width="60%" ClientEnabled="false"></dx:ASPxTextBox>
                            </td>
                            <td colspan="2" style="text-align: right">
                                <label id="label" style="color: blue;">水量单位：立方米</label>

                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;">用户名：</td>
                            <td colspan="3">
                                <dx:ASPxTextBox runat="server" ID="txtYongHuM" ClientInstanceName="txtYongHuM" Width="80%" ClientEnabled="false"></dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;">井编号：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtJingBianH" ClientInstanceName="txtJingBianH" Width="60%" ClientEnabled="false"></dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;">本月抄码：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtBenYueCM" ClientInstanceName="txtBenYueCM" Width="60%" ClientEnabled="false">
                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);}"/>
                                </dx:ASPxTextBox>
                            </td>
                            <td style="text-align: right;">上月抄码：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtShangYueCM" ClientInstanceName="txtShangYueCM" Width="60%" ClientEnabled="false"></dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;">本月水量：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtBenYueSL" ClientInstanceName="txtBenYueSL" Width="60%" ClientEnabled="false">
                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);}"/>
                                </dx:ASPxTextBox>
                            </td>
                            <td style="text-align: right;">上月水量：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtShangYueSL" ClientInstanceName="txtShangYueSL" Width="60%" ClientEnabled="false"></dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;">确认本月水量：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtQueRenBYSL" ClientInstanceName="txtQueRenBYSL" Width="60%" ClientEnabled="false">
                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);}"/>
                                </dx:ASPxTextBox>
                            </td>
                            <td style="text-align: right;">开帐水量：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtKaiZhangSL" ClientInstanceName="txtKaiZhangSL" Width="60%" ClientEnabled="false"></dx:ASPxTextBox>
                            </td>
                        </tr>
                    </table>
                </div>
                <div>
                    <table style="width:100%;margin-top:10px;">
                        <tr>
                            <td style="text-align: right;">
                                <dx:ASPxButton runat="server" ID="btnEdit" ClientInstanceName="btnEdit" Text="修改" UseSubmitBehavior="false" AutoPostBack="false">
                                    <ClientSideEvents Click="function(s,e){edit();}"/>
                                </dx:ASPxButton>
                            
                                <dx:ASPxButton runat="server" ID="btnKZ" ClientInstanceName="btnKZ" Text="保存并重新开帐" UseSubmitBehavior="false" AutoPostBack="false" ClientEnabled="false">
                                    <ClientSideEvents Click="function(s,e){kz();}"/>
                                </dx:ASPxButton>
                                <dx:ASPxButton runat="server" ID="btnCancel" ClientInstanceName="btnCancel" Text="放弃" UseSubmitBehavior="false" AutoPostBack="false" ClientEnabled="false">
                                    <ClientSideEvents Click="function(s,e){cancel();}"/>
                                </dx:ASPxButton>             
                            </td>
                        </tr>
                    </table>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
